const { contextBridge, ipcRenderer } = require('electron');
contextBridge.exposeInMainWorld('electron', {
  navigate: (page) => ipcRenderer.send('navigate', page),
});

contextBridge.exposeInMainWorld(
  'electronAPI', {
    send: (channel, data) => {
      let validChannels = ["set-email", "set-email-list", "add-email"]; // 发送数据的通道
      if (validChannels.includes(channel)) {
        ipcRenderer.send(channel, data);
      }
    },
    receive: (channel, func) => {
      let validChannels = ['get-email', "get-email-list", "email-added"]; // 接收数据的通道
      if (validChannels.includes(channel)) {
        ipcRenderer.on(channel, (event, ...args) => func(...args));
      }
    }
  }
);